const config = require('./config.js')

function post({ data, url, success, fail }) { //发送请求
    data = data || {}
    data.key = config.key
    wx.request({
        method: 'post',
        url: config.requestUrl + url,
        data: data,
        success(res) {
            success && success(res.data)
        },
        fail() {
            wx.showModal({
                title: '错误',
                content: '数据请求发生错误，请稍后重试',
                showCancel: false
            })
            fail && fail()
        }
    })
}


module.exports = {
    post
}